package com.mzj.saas.jobs.backlog.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import com.mzj.saas.jobs.backlog.entity.BacklogItem;

public interface BacklogItemRepository extends PagingAndSortingRepository<BacklogItem, Long>, JpaSpecificationExecutor<BacklogItem> {

	BacklogItem findByHouseIdAndTypeAndHandleStatus(String houseId,Integer type,Integer handleStatus);


	@Query(value = "select * from saas_backlog_item where (match_user_id is null and  phone  is not null ) ", nativeQuery = true)
	List<BacklogItem> findByMatchUserIdAndPhone(String matchUserId, String phone);

	@Query("from BacklogItem  where houseId=?1 and type=?2 and DATE_FORMAT(create_time, '%Y-%m-%d') = ?3")
	BacklogItem findByHouseIdAndType(String houseId, Integer type, String date);



	List<BacklogItem> findByMatchUserId(String matchUserId);

	int deleteByIdIn(List<Long> ids);

	BacklogItem findByHouseIdAndMatchUserIdAndType(String houseId, String matchUserId, Integer type);

	int deleteByHouseIdAndType(String houseId, Integer type);
}
